<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="box"></div>


    <script>
        console.log(location.href);
        // console.log(id);
        function getlist() {
            let box = document.querySelector('.box')
            let id = location.href.split('?')[1]
            let xhr = new XMLHttpRequest()
            xhr.open('post', 'https://bookapi.zongheng.com/api/chapter/getChapterList')
            xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded')
            xhr.send(`bookId=${id}`)
            // xhr.send(`bookId=408586`)
            xhr.onreadystatechange = function(){
                if(xhr.readyState ==4){
                    let data = JSON.parse(xhr.responseText)
                    console.log(data);
                    let lists = data.result.chapterList[0].chapterViewList
                    for(let i= 0;i<lists.length;i++){
                        let name = lists[i].chapterName
                        let p = document.createElement('p')
                        p.innerHTML = name
                        box.appendChild(p)
                    }
                    
                }
            }




        }
        getlist()




    </script>
</body>

</html>